//学校对象

var schoolObj = {
	"huaying" : {
		title : '天津华英学校--快乐暑期名师串讲',
		innerTitle : '天津华英学校',
		subTitle : '快乐暑期名师串讲',
		backgroundImg : 'img/download/xjkPC.jpg',
		backgroundPhoneImg : 'url(img/download/huayingDianhua.png)',
		phoneImg : 'img/download/huayingPhone.jpg'
	},
	"shuangshi" : {
		title : '厦门双十中学  新高一衔接课',
		innerTitle : '厦门双十中学',
		subTitle : '新高一衔接课',
		backgroundImg : 'img/download/xjkPC.jpg',
		backgroundPhoneImg : 'url(img/download/dianhua.png)',
		phoneImg : 'img/download/xjkPhone.jpg'
	},
	"tianli" : {
		title : '天利名校高考模拟试题专讲',
		innerTitle : '天利',
		subTitle : '名校高考模拟试题专讲',
		backgroundImg : 'img/download/xjkPC.jpg',
		backgroundPhoneImg : 'url(img/download/dianhua.png)',
		phoneImg : 'img/download/tianliPhone.jpg'
	},
	"xdf_liuxue" : {
		title : '新东方出国留学',
		innerTitle : '新东方出国留学 ',
		subTitle : '',
		backgroundImg : 'img/download/liuxuePC.jpg',
		backgroundPhoneImg : 'url(img/download/liuxueTell.png)',
		phoneImg : 'img/download/liuxuePhone.jpg'
	},
	"xdf_zhongzhao" : {
		title : '厦门中招--中招志愿大会',
		innerTitle : '厦门中招    ',
		subTitle : '七月七日，中招志愿大会',
		backgroundImg : 'img/download/zhongzhaoPC.jpg',
		backgroundPhoneImg : 'url(img/download/产品图片.png)',
		phoneImg : 'img/download/zhongzhaoPhone.jpg'
	},
	"shuangshi_zz" : {
		title : '厦门双十中学漳州分校  ',
		innerTitle : '  厦门双十中学漳州分校    ',
		subTitle : '暑假特色校本作业',
		backgroundImg : 'img/download/xjkPC.jpg',
		backgroundPhoneImg : 'url(img/download/dianhua_zhangzhou.png) ',
		phoneImg : 'img/download/衔接课1.jpg'
	},
	"gzs_fj":{
		title:'福建名师工作室',
		innerTitle:'福建名师工作室',
		subTitle:'托起你成长之路',
		backgroundImg:'img/download/xjkPC.jpg',
		backgroundPhoneImg : 'url(img/download/gzs_fj_dianhua.png) ',
		phoneImg:'img/download/gzs_fj_phone.jpg'
	}
};

require(["mmRouter"],function () {
	var model = avalon.define("mean", function(vm) {
		vm.currentObj = {};
		vm.title = "";
		vm.innerTitle = "";
		vm.subTitle = "";
		vm.backgroundImg = "";
		vm.backgroundPhoneImg = "";
		vm.tpl="";		
	});
	
	
	//路由
	avalon.router.get("/{schoolId}/",routeCallBack);
	
	//路由回调
	function routeCallBack(){
		//参数对象
		var params = this.params;
		var schoolId = params.schoolId;
		
		var currentSchool = schoolObj[schoolId];
		
		if(typeof currentSchool =='undefined'){
			currentSchool = schoolObj.shuangshi;
			schoolId = "shuangshi";
		}
		
		//设置内容
		for(var prop in currentSchool){
			model[prop] = currentSchool[prop];
		}
		model.currentObj = currentSchool;
		
		//設置模板
		model.tpl = "./schoolphone_parts/"+schoolId+".html";
		
		__setWH();
		$(window).resize(function(){
			__setWH();
		});
		
	};
	
	avalon.history.start({
	    basepath: "/avalon"
	});
	
	
	
	if(__isPC()){
		$('#iosDownloadLink').attr('href','javascript:void(0)');
		$('#iosDownloadLink').text('请扫描二维码下载');
	}

	//设置宽高
function __setWH(){
	var getW=document.body.clientWidth;
    
    if(getW<1000){
    	model.backgroundImg = model.currentObj.phoneImg;
    	
    	$(".myCenter,.yunImg").hide();
    	$(".btnPhone").show();
    	
    }else{    	
    	model.backgroundImg = model.currentObj.backgroundImg;
    	$(".myCenter,.yunImg").show();
    	$(".btnPhone").hide();
    }
    __android_or_ios($(".btnPhone"));

};

//判断终端类型
function __android_or_ios(obj){
	var u = navigator.userAgent, app = navigator.appVersion;
	var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
	var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	if(is_weixin()){
		obj.on('click',function(){
			$("#mcover").css('display','block');
		});
		
	}else if(isAndroid){
		obj.attr("href","http://udodl.howdo.cc/xjk/udo_stu.apk");
	}else if(isiOS){
		obj.attr("href","itms-services://?action=download-manifest&amp;url=https://dn-udodl.qbox.me/udo2/20150625/1/manifest.plist");
		if(document.body.clientWidth==768){
			$('.btnPhone').css({
				top:'60%'
			});			
		}
	}
};

//判读是否是pc
function __isPC(){  
     var userAgentInfo = navigator.userAgent;
     var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");  
     var flag = true;  
     for (var v = 0; v < Agents.length; v++) {  
         if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }  
     }  
     return flag;  
  }


	avalon.scan();
});

